<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>

    <h:form id="event" styleClass="edit">
    
        <rich:panel>
            <f:facet name="header">#{eventHome.managed ? 'Edit' : 'Add'} Event</f:facet>



            <s:decorate id="descriptionDecoration" template="layout/edit.xhtml">
                <ui:define name="label">description</ui:define>
                <h:inputTextarea id="description"
                               cols="80"
                               rows="3"
                              value="#{eventHome.instance.description}"/>
            </s:decorate>



            <s:decorate id="nameDecoration" template="layout/edit.xhtml">
                <ui:define name="label">name</ui:define>
                <h:inputTextarea id="name"
                               cols="80"
                               rows="3"
                              value="#{eventHome.instance.name}"/>
            </s:decorate>

        
            <div style="clear:both">
                <span class="required">*</span> 
                required fields
            </div>
            
        </rich:panel>
                
        <div class="actionButtons">

            <h:commandButton id="save" 
                          value="Save" 
                         action="#{eventHome.persist}"
                       disabled="#{!eventHome.wired}"
                       rendered="#{!eventHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="Save" 
                         action="#{eventHome.update}"
                       rendered="#{eventHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="Delete" 
                         action="#{eventHome.remove}"
                      immediate="true"
                       rendered="#{eventHome.managed}"/>
                    
            <s:button id="done" 
                   value="Done"
             propagation="end"
                    view="/Event.xhtml"
                rendered="#{eventHome.managed}"/>
                
            <s:button id="cancel" 
                   value="Cancel"
             propagation="end"
                    view="/#{empty eventFrom ? 'EventList' : eventFrom}.xhtml"
                rendered="#{!eventHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="gamesets">
        <div class="association" id="gamesetsChildren">
        
            <h:outputText value="There are no gamesets associated with this event." 
                       rendered="#{empty eventHome.gamesets}"/>
        
            <rich:dataTable value="#{eventHome.gamesets}" 
                           var="gameset" 
                      rendered="#{not empty eventHome.gamesets}" 
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="gamesetsTable">
                <h:column>
                    <f:facet name="header">id</f:facet>
                    <h:outputText value="#{gameset.id}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">description</f:facet>
                    <h:outputText value="#{gameset.description}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">name</f:facet>
                    <h:outputText value="#{gameset.name}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">action</f:facet>
                    <s:link view="/Gameset.xhtml" 
                              id="selectgameset" 
                           value="Select"
                     propagation="none">
                        <f:param name="gamesetId" 
                                value="#{gameset.id}"/>
                        <f:param name="gamesetFrom" value="Event"/>
                    </s:link>
                </h:column>
            </rich:dataTable>
        
        </div>
          
        <f:subview rendered="#{eventHome.managed}" id="gamesets">
        <div class="actionButtons">
            <s:button id="addgameset" 
                   value="Add gameset"
                    view="/GamesetEdit.xhtml"
             propagation="none">
                 <f:param name="eventId" 
                         value="#{eventHome.instance.id}"/>
                 <f:param name="gamesetFrom" value="Event"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
    
    <rich:tab label="player">
    <div class="association" id="playerParent">
    
        <h:outputText value="There is no player associated with this event." 
                   rendered="#{eventHome.instance.player == null}"/>
        
        <rich:dataTable var="player" 
                   value="#{eventHome.instance.player}" 
                rendered="#{eventHome.instance.player != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="playerTable">
            <h:column>
                <f:facet name="header">id</f:facet>
                #{player.id}
            </h:column>
            <h:column>
                <f:facet name="header">name</f:facet>
                #{player.name}
            </h:column>
            <h:column>
                <f:facet name="header">action</f:facet>
                <s:link view="/Player.xhtml" 
                         id="viewplayer" 
                      value="View" 
                propagation="none">
                    <f:param name="playerId" 
                           value="#{player.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="Select player"
                       view="/PlayerList.xhtml">
                <f:param name="from" value="EventEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
